<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<title>优惠活动</title>
		<%@include file="/WEB-INF/base.jspf"%>
		<style>
			body {
				margin:0;
			}
			.main {
			}
			#div-i-noticeList {
				overflow-y:auto;
				-webkit-overflow-scrolling : touch;
				padding: 4vh 2vh;
			}
			#div-i-noticeList .div-c-detailItem {
				background: #fff;
			    border: 1px solid #ddd;
			    width: 96%;
			    margin: 0 auto 10px;
			    box-sizing: border-box;
			    padding: 10px 15px 0;
			    border-radius: 5px;
			    cursor: pointer;
			    display:flex;
			    flex-direction:column;
			}
			.div-c-detailItem .title {
				font-weight:bold;
				font-size:18px;
			}
			.div-c-detailItem .text {
				color: silver;
				font-size:14px;
				padding: 6px;
			}
			.div-c-detailItem img {
				background-size: cover;
				max-width: 100%;
				max-height:200px;
			}
			.detailText {
				border-top:1px solid #ddd;
				padding-bottom:6px;
				padding-top:6px;
				color:#969595;
			}
		</style>
	</head>

	<body style="background: #F1F1F1 ;">
		<div id="loading" class="kd-loading">
	<div class="kd-spinner">
		<span class="bounce b1"></span>
		<span class="bounce b2"></span>
		<span class="bounce b3"></span>
	</div>
	<p>&nbsp;</p>
	<p>&nbsp;</p>
	<p>请稍等，努力加载中...</p>
</div>
<div class='wapper' style="display:none">
		<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center" style="height: 50px;line-height:50px;position: fixed;margin-top: 0px;left: 0px;z-index: 100;background-color:#059BF3;">
			<!-- onclick="back()" -->
			<a id="fanhui-a" href="/sy.do" class="glyphicon glyphicon-chevron-left fl" style="cursor:pointer; color: white;position:absolute;top:50%;transform:translateY(-50%);font-size: 20px;left:10px;"></a>
			<strong style="font-size: 20px;color: white;">优惠活动</strong>
		</div>
		<div style="height:50px;"></div>
        <div style="" id="div-i-noticeList" class="col-xs-12 col-sm-4 col-sm-offset-4 ">
        </div>
        </div>
	</body>
	<script type="text/javascript">
	document.onreadystatechange = function(){ 
		　　 if(document.readyState == "complete"){ 　　//当页面加载状态为完全结束时进入 
		    　 //你要做的操作。
			 $(".wapper").show() 
			 $(".kd-loading").hide()
		   　 }
		}
	var BASE_SRC = "/"
	function newActiveItem(item) {
		var html = "<div class='div-c-detailItem' data-id='" + item.id + "'>"+
			"<span class='title'>" + item.name + "</span>"+
			"<img src='/d/cp/" + item.photo_path + "' />"+
			"<span class='detailText'>点击查看活动详情</span>"
		"</div>"
		return html
	}
	
	//
	
	var USER_MOVE = false
	$("#div-i-noticeList").on("touchstart", ".div-c-detailItem", function(e) {
		USER_MOVE = false
	})
	$("#div-i-noticeList").on("touchmove", ".div-c-detailItem", function(e) {
		USER_MOVE = true
	})
	$("#div-i-noticeList").on(getEndClickEvent(), ".div-c-detailItem", function(e) {
		if (USER_MOVE) {
			return
		}
		var idValue = $(e.currentTarget).attr("data-id")
		window.location.href = "/youhuiDetailjsp.do?" + "id=" + idValue
	})	
	
	function initActivityList(data) {
		var $noticeList = $("#div-i-noticeList")
		$noticeList.html("")
		for (var i = 0; i < data.length; i++) {
			var html = newActiveItem(data[i])
			$noticeList.append(html)
		}
	}
	
	ajax({
		url: "/act/allActivity.do",
		type: "post",
		data: {},
		success: function(data) {
			if (data.indexOf("<!DOCTYPE html>") != -1) {
				return
			}
			var newData = JSON.parse(data)
			if (newData.data.length === 0) {
				$("#div-i-noticeList").html("<p style='text-align:center;'>暂无正在进行中的优惠活动</p>")				
			} else {
				initActivityList(newData.data)
			}
		},
		error: function(status) {
			showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "网络繁忙")
		}
	}) 
	 var stopUserScaleScreen = function() {
			window.onload= function () {
			    document.addEventListener('touchstart',function (event) {
			        if(event.touches.length>1){
			            event.preventDefault();
			        }
			    })
			    var lastTouchEnd=0;
			    document.addEventListener('touchend',function (event) {
			        var now=(new Date()).getTime();
			        if(now-lastTouchEnd<=300){
			            event.preventDefault();
			        }
			        lastTouchEnd=now;
			    },false)
			}
 			$("body").on("touchstart touchmove", function(event) {
				if (event.target.closest("#div-i-noticeList") == null) {
					event.preventDefault()
				}
			})		
	  } 	  
		<%-- $("#fanhui-a").on("click",function(){
			$().
		}) --%>
	  var __main = function() {
		  stopUserScaleScreen()
	  }
	  __main()
	</script>
</html>